<?php
/**
 * 日志记录
 * Enter description here ...
 * @author Code.404
 *
 */
class LogModel extends Model {
	
	function writeLog($remark = ''){
		if(IS_SAE){
			$this->logToDb($remark);
		}else{
			$this->logToFile($remark);
		}
	}
	private function logToDb($remark = ''){
		$_data['log_time'] = time();
		$_data['log_user'] = $_SESSION['admin_user']['username'];
		$_data['log_url'] = __SELF__;
		$_data['log_remark'] = $remark;
		$_data['log_ip'] = get_client_ip();

		$this->add($_data);
	}
	
	private function logToFile($remark = ''){
		$message = "操作用户: {$_SESSION['admin_user']['username']}\t  , 操作者IP：" . get_client_ip() . "\t  , 备注 : {$remark}";
		Log::write($message , Log::INFO, '','./Data/logs/log-' .date('Y-m-d') . '.log');
	}
}